package com.fr.util;

import java.awt.event.KeyEvent;

public class KeyEventWork
{
  private static long lastKeyTime;
  private static int last;
  private static final int LAST_NOTHING = 0;
  private static final int LAST_ALT = 1;
  private static final int LAST_BROKEN = 2;
  private static final int LAST_NUMKEYPAD = 3;
  private static final int LAST_MOD = 4;

  public static KeyEvent processKeyEvent(KeyEvent paramKeyEvent)
  {
    int i = paramKeyEvent.getKeyCode();
    char c = paramKeyEvent.getKeyChar();
    switch (paramKeyEvent.getID())
    {
    case 401:
      switch (i)
      {
      case 0:
      case 16:
      case 17:
      case 18:
      case 128:
      case 129:
      case 130:
      case 131:
      case 132:
      case 133:
      case 134:
      case 135:
      case 136:
      case 137:
      case 138:
      case 139:
      case 140:
      case 141:
      case 142:
      case 143:
      case 157:
      case 65406:
        return null;
      }
      switch (i)
      {
      case 96:
      case 97:
      case 98:
      case 99:
      case 100:
      case 101:
      case 102:
      case 103:
      case 104:
      case 105:
      case 106:
      case 107:
      case 109:
      case 110:
      case 111:
        last = 3;
        lastKeyTime = System.currentTimeMillis();
        return paramKeyEvent;
      case 108:
      }
      handleBrokenKeys(paramKeyEvent, i);
      return paramKeyEvent;
    case 400:
      if ((((c < ' ') || (c == '') || (c == 255) || (c == '\b'))) && (c != '\t'))
        return null;
      if (((paramKeyEvent.isControlDown() ^ paramKeyEvent.isAltDown())) || (paramKeyEvent.isMetaDown()))
        return null;
      if (last == 4)
        switch (c)
        {
        case '!':
        case ',':
        case '?':
        case 'B':
        case 'M':
        case 'X':
        case 'c':
          last = 0;
          return null;
        }
      if ((last == 3) && (System.currentTimeMillis() - lastKeyTime < 750L))
      {
        last = 0;
        if ((((c < '0') || (c > '9'))) && (c != '.') && (c != '/') && (c != '*') && (c != '-') && (c != '+'))
          break label592;
        return null;
      }
      if ((last == 2) && (System.currentTimeMillis() - lastKeyTime < 750L) && (!(Character.isLetter(c))))
      {
        last = 0;
        return null;
      }
      if ((last == 1) && (System.currentTimeMillis() - lastKeyTime < 750L))
      {
        last = 0;
        return null;
      }
      return paramKeyEvent;
    case 402:
      label592: return paramKeyEvent;
    }
    return paramKeyEvent;
  }

  public static void numericKeypadKey()
  {
    last = 0;
  }

  private static void handleBrokenKeys(KeyEvent paramKeyEvent, int paramInt)
  {
    if ((paramKeyEvent.isAltDown()) && (paramKeyEvent.isControlDown()) && (!(paramKeyEvent.isMetaDown())))
    {
      last = 0;
      return;
    }
    if ((!(paramKeyEvent.isAltDown())) && (!(paramKeyEvent.isControlDown())) && (!(paramKeyEvent.isMetaDown())))
    {
      last = 0;
      return;
    }
    if (paramKeyEvent.isAltDown())
      last = 1;
    switch (paramInt)
    {
    case 8:
    case 9:
    case 10:
    case 37:
    case 38:
    case 39:
    case 40:
    case 127:
      last = 0;
      break;
    default:
      if ((paramInt < 65) || (paramInt > 90))
        last = 2;
      else
        last = 0;
    }
    lastKeyTime = System.currentTimeMillis();
  }
}